Skip to content

Cross-compatible hook/middleware + "plugins" which are allowed to be hook and middleware#1284

Open
brandur wants to merge 1 commit into
masterfrom
brandur-plugins
Open

Cross-compatible hook/middleware + "plugins" which are allowed to be hook and middleware#1284
brandur wants to merge 1 commit into
masterfrom
brandur-plugins

Conversation

@brandur

@brandur brandur commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This one's largely aimed at extending a few parts of otelriver to be
able to emit some additional useful metrics like time that it takes to
lock jobs, number of jobs locked per batch, or any other arbitrary
metrics we want to emit down the road. I previously had something
similar back in #1203, but here we extract an isolated piece of it.

This change does two things:

  • If either a hook sent to Config.Hooks implements a middleware or a
    middleware sent to Config.Middleware implements a hook, activate its
    alternate side as well.

  • Establish a new Config.Plugins that acts as a more generalized place
    where a hook/middleware can go. We define a plugin as this type:

      type Plugin interface {
          Hook
          Middleware
      }
    

The reason for the first point is better backward compatibility.
Notably, if I add a hook to otelriver.Middleware, I want it to be able
to still work even if the user doesn't explicitly movie it from
Config.Middleware to Config.Plugins.

…hook and middleware

This one's largely aimed at extending a few parts of `otelriver` to be
able to emit some additional useful metrics like time that it takes to
lock jobs, number of jobs locked per batch, or any other arbitrary
metrics we want to emit down the road. I previously had something
similar back in #1203, but here we extract an isolated piece of it.

This change does two things:

* If either a hook sent to `Config.Hooks` implements a middleware or a
  middleware sent to `Config.Middleware` implements a hook, activate its
  alternate side as well.

* Establish a new `Config.Plugins` that acts as a more generalized place
  where a hook/middleware can go. We define a plugin as this type:

        type Plugin interface {
            Hook
            Middleware
        }

The reason for the first point is better backward compatibility.
Notably, if I add a hook to `otelriver.Middleware`, I want it to be able
to still work even if the user doesn't explicitly movie it from
`Config.Middleware` to `Config.Plugins`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant